package property.personal.property_mange.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import property.personal.property_mange.pojo.Propertyinfo;
import property.personal.property_mange.service.impl.EditImpl;

@Controller
public class EditController {

    @Autowired
    EditImpl editimpl;

    @RequestMapping("/getedit")
    public String getedit(@RequestParam("id") Long id, Model model){
        Propertyinfo pro=editimpl.getedit(id);
        model.addAttribute("property",pro);

        return "editproperty";
    }

    @ResponseBody
    @RequestMapping("/editbyid")
    public int editbyid(@RequestParam("id") String id,@RequestParam("names") String name,@RequestParam("code") int code,@RequestParam("director") String director,@RequestParam("telphone") String  telphone
    ,@RequestParam("password") String password,@RequestParam("address") String address,@RequestParam("logo") String logo,@RequestParam("indroduce") String indroduce){
        String logo2=logo.substring(8);

        int n=editimpl.editbyid(name,code,director,telphone,password,address,logo2,id,indroduce);
        return n;
    }
}
